" vim:ft=vim

Execute(test-titleposition):
  function! GetTitleTopline() abort
    if has('nvim')
      let bd_winid = getbufvar(bufnr('%'), 'floaterm_borderwinid')
      return getbufline(winbufnr(bd_winid), 1)[0]
    else
      return popup_getoptions(win_getid()).title
    endif
  endfunction

  Log 'left-align'
    FloatermNew --title=title --titleposition=left
    if has('nvim')
      Assert GetTitleTopline() =~ '^.title'
    else
      Assert GetTitleTopline() =~ '^title'
    endif

  Log 'right-align'
    FloatermNew --title=title --titleposition=right
    if has('nvim')
      Assert GetTitleTopline() =~ 'title.$'
    else
      Assert GetTitleTopline() =~ 'title$'
    endif

  Log 'center - even width'
    FloatermNew --width=8 --title=1234 --titleposition=center
    if has('nvim')
      Assert GetTitleTopline() =~ '..1234..'
    else
      Assert GetTitleTopline() =~ '.1234.'
    endif

  Log 'center - odd width'
    FloatermNew --width=8 --title=123 --titleposition=center
    if has('nvim')
      Assert GetTitleTopline() =~ '..123...'
    else
      Assert GetTitleTopline() =~ '.123..'
    endif

  FloatermKill!
  stopinsert

